//
//  RwData.h
//  rwipad
//
//  Created by S W Consultancy on 26/08/2011.
//  Copyright 2011 SW Consultancy. All rights reserved.
//
// My idea here is to provide a simple interface to the file system.
// Hiding all the infrastructure stuff!
//
// I have implemented a singleton so that several files can be shared and open 
// at the same time.
//
// keys (must be|are) unique.
// values can be sring or int
// can be treated as an array (keys are index)
// You should never have to save as it is always done on every update.
// I assume updates are infrequent (based on user input)

#import <Foundation/Foundation.h>

@interface RwData : NSObject {

    NSString *root;
    NSString *bundle_path;
    NSString *save_path;
    NSString *short_name;
    NSString *long_name;
    NSMutableDictionary *dict;
    
}

-(NSDictionary*)dict;

+(RwData*)singleton: (NSString*) pListName; // e.g instance :@"fred" for fred.plist

-(NSString*)read :(NSString*)key;
-(int)readAsInt :(NSString*)key;

-(void)write :(NSString*)key :(NSString*)value;
-(void)writeAsInt :(NSString*)key :(int)value;

-(void)remove :(NSString*)key;

-(NSString*)readAtIndex :(int)key;
-(void)writeAtIndex :(int)key :(NSString*)value;
-(void)insertAtIndex :(int)key :(NSString*)value;
-(void)insertAtEnd :(NSString*)value;
-(void)removeAtIndex: (int)key;

-(void)empty;
-(int)count;
-(void)save;

@end
